<template>
    <div class="Home">
        <mt-header fixed title="主页">
            <mt-button slot="right" @click="logout">退出登陆</mt-button>
        </mt-header>
        <div class="home" style="margin-top: 40px; width: 100%;" >
            <table  cellpadding="0" cellspacing="0">
                <tr>
                    <td style="border-left: 1px solid #eaeaea;">
                        <router-link to="/viewdata">
                            <div class="boder">
                                <i class="icon iconfont icon-shujuchaxun"></i>
                                <div class="name">数据查询</div>
                            </div>
                        </router-link>
                    </td>
                    <td>
                        <router-link to="/selectreview">
                            <div class="boder" style="position: relative">
                                <i class="icon iconfont icon-wyrz02"></i>
                                <div class="name">审核资质</div>
                                <div class="icoHome">{{authCount}}</div>
                            </div>
                        </router-link>

                    </td>
                    <td>
                        <router-link to="/reportList">
                        <div class="boder" style="position: relative">
                            <i class="icon iconfont icon-jubao"></i>
                            <div class="name">审核举报</div>
                            <div class="icoHome">{{complaitCount}}</div>
                        </div>
                        </router-link>
                    </td>
                    </td>
                </tr>
                <tr>
                    <td>
                        <router-link to="/reflectedlist">
                            <div class="boder" style="position: relative">
                                <i class="icon iconfont icon-lijitixian"></i>
                                <div class="name">审核提现</div>
                                <div class="icoHome">{{crash}}</div>
                            </div>
                        </router-link>
                    </td>
                    <td>
                        <router-link to="/userList">
                            <div class="boder" style="position: relative">
                                <i class="icon iconfont icon-navicon12"></i>
                                <div class="name">用户管理</div>
                                <div class="icoHome">{{userCount}}</div>
                            </div>
                        </router-link>
                    </td>
                    <td v-show="isshowSuper">
                        <router-link to="/management">
                            <div class="boder" style="position: relative">
                                <i class="icon iconfont icon-addition"></i>
                                <div class="name">管理员</div>
                                <div class="icoHome">{{opsUserCount}}</div>
                            </div>
                        </router-link>

                    </td>
                </tr>
            </table>
        </div>

    </div>
</template>

<script>
    import {
            back,
            isspuer,
            loading,
            logout,
            authcount
    } from '../common/api/api';
    import { Toast ,Indicator} from 'mint-ui';
    export default {
        name: 'Home',
        data () {
            return {
                isshowSuper : false,
                createDialog: {
                    opened: false,
                    loading: false
                },
                authCount : null,
                complaitCount : null,
                crash : null,
                opsUserCount : null,
                userCount : null,
            }
        },
        components: {
            //Hello
        },
        methods: {
            back : back,
            logout : function () {
                var vm = this;
                loading(true);
                logout({}, {
                    target: vm.createDialog
                })
                        .then((data) => {
                            console.log(data);
                            vm.createDialog.opened = false;
                            if(data.errno == 0){
                                loading(false);
                                Toast(data.data);
                                this.$router.push('/');
                            }else{
                                loading(false);
                                Toast(data.errmsg);
                            }

                        });
            },
            init : function () {
                var vm = this;
                loading(true);
                authcount({}, {
                    target: vm.createDialog
                })
                        .then((data) => {
                            console.log(data);
                            vm.createDialog.opened = false;
                            if(data.errno == 0){
                                loading(false);
                                vm.authCount = data.data.authCount;
                                vm.complaitCount = data.data.complaitCount;
                                vm.crash = data.data.crash;
                                vm.userCount = data.data.userCount;
                                vm.opsUserCount = data.data.opsUserCount;
                            }else{
                                loading(false);
                                Toast(data.errmsg);
                            }

                        });
            }
        },
        created() {
            var vm = this;
            loading(true);
            isspuer({}, {
                target: vm.createDialog
            })
                    .then((data) => {
                        console.log(data);
                        vm.createDialog.opened = false;
                        if(data.errno == 0){
                            loading(false);
                            vm.isshowSuper = data.data;
                        }else{
                            loading(false);
                            Toast(data.errmsg);
                        }

                    });
            vm.init();
        },

    }
</script>
